package cn.pzhu.javaee.mybook.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.pzhu.javaee.mybook.dao.CatogeryDao;
import cn.pzhu.javaee.mybook.domain.Catogery;
import cn.pzhu.javaee.webapp.servlet.WebAppBaseServlet;

/**
 * Servlet implementation class CommonDataServlet
 */
@WebServlet("/comm")
public class CommonDataServlet extends WebAppBaseServlet {
	private static final long serialVersionUID = 1L;
	private CatogeryDao dao=new CatogeryDao();
    /*
     * http://localhost:8080/comm?json=catogery&type=收
     */
	public void jsonCatogery(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		log.debug("jsonCatogery");
		String type=this.getString(request, "type");
		List<Catogery> ctgList=dao.listByType(type);
		this.sendJson(response, ctgList);
	}

}
